<template>
    <div class="header">
        <i class="iconfont icon-qianjin-copy" v-if="iconShow==1" @click="iconClick"></i>
        <i class="red-spot" v-if="newMessage"></i>
        {{title}}
        <slot name="icon"></slot>
    </div>
</template>
<script>
export default {
    name: 'header1',
    props: ['title', 'iconShow','pullRight','pullCB','newMessage'],
    mounted(){
        // 获取请求参数
        function getParameter(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r !== null) {
                return decodeURI(r[2]);
            }
            return null;
        }
    },
    methods: {
        iconClick() {
            // if(this.$route.query.history&&this.$route.query.history==1){
            //     this.$router.push({path:'/main/home'});
            // }else if(this.$route.query.index&&this.$route.query.fromBanner!=1){
            //     this.$router.push({path:'/main/recommentproduct',query:{index:this.$route.query.index}})
            // }else if((window.location.href.split('#')[1].indexOf('mydiscover')!=-1&&!this.$route.query.id)||(window.location.href.split('#')[1].indexOf('myfavorite')!=-1&&!this.$route.query.id)||(window.location.href.split('#')[1].indexOf('mycomment')!=-1&&!this.$route.query.id)){
            //     console.log(window.location.href.split('#'));
            //     this.$router.push({path:'/main/mine'});
            // }
            // else{
            //     this.$router.go(-1);
            // }
            let path=window.location.href.split('/');
            if(path[path.length-1].indexOf('collectZiXun')!=-1||
               path[path.length-1].indexOf('collectProduct')!=-1||
               path[path.length-1].indexOf('collectTieZi')!=-1||
               path[path.length-1].indexOf('mydiscoverProduct')!=-1||
                path[path.length-1].indexOf('mydiscoverZiXun')!=-1||
                path[path.length-1].indexOf('mydiscoverTieZi')!=-1
               ){
                    window.location.href="/mine/mine.html";
               }else{
                    window.history.go(-1);         
               }
        },
        getCash(){
            console.log(1);
        }
    }
}
</script>
<style lang="scss">
// @import '../../../scss/base.scss';
.header {
    background: -webkit-linear-gradient(bottom, #2ce9e8, #7dd7ff);
    position: fixed;
    top: 0;
    z-index: 10;
    width: 100%;
    height: 1.2rem;
    // background: $primaryColor;
    color: #fff;
    text-align: center;
    font-size: 0.42rem;
    line-height: 1.2rem;
    .icon-qianjin-copy {
        position: absolute;
        left: 0.4rem;
        color: #fff;
    }
    .icon-wenhao {
        position: absolute;
        right: 0;
        margin-right: 0.4rem;
        font-size: 0.6rem;
    }
    .icon-icon_liwu_w{
        position: absolute;
        right: 0;
        margin-right: 0.4rem;
        font-size: 0.6rem;
    }
      .icon-laba-bg {
        display: block;
        position: absolute;
        top: 0.3rem;
        right: 0.1rem;
        width: 0.8rem;
        height: 0.8rem;
        // background: url($url+"/static/img/icon32/laba@2x.png") no-repeat;
        background: url("../../assets/icon/laba@2x.png") no-repeat;
        background-size: 0.6rem;
    }
    .submit{
        position: absolute;
        right: 0;
        margin-right: 0.4rem;
        font-size: 0.4rem;
    }
    .red-spot {
        display: block;
        position: absolute;
        width: 0.3rem;
        height: 0.3rem;
        // background: url($url+"/static/img/icon32/dian@2x.png") no-repeat;
        background: url("../../assets/icon/dian@2x.png") no-repeat;
        background-size: 0.3rem;
        top: 0.25rem;
        right: 0.15rem;
        z-index: 99;
    }
}
</style>


